package com.topvision.controller.sys;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topvision.model.sys.SysCompany;
import com.topvision.service.sys.SysCompanyService;
import com.topvision.util.PageUtils;
import com.topvision.util.Query;
import com.topvision.util.R;
import com.topvision.controller.AbstractController;

/**
 * 公司表
 *
 * @author shengwm
 * @email 179653076@qq.com
 * @date 2018-03-14 23:22:24
 */
@RestController
@RequestMapping("sys/syscompany")
public class SysCompanyController extends AbstractController {
    @Autowired
    private SysCompanyService sysCompanyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys/syscompany:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<SysCompany> sysCompanyList = sysCompanyService.queryList(query);
        int total = sysCompanyService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(sysCompanyList, total, query.getLimit(), query.getPage());

        return R.success().put("page", pageUtil);
    }

    @RequestMapping("/findListByParam")
    @RequiresPermissions("sys/syscompany:list")
    public R findListByParam(@RequestParam Map<String, Object> params){

        List<SysCompany> sysCompanyList = sysCompanyService.queryByParam(params);

        return R.success().put("sysCompanyList", sysCompanyList);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys/syscompany:info")
    public R info(@PathVariable("id") Long id){
        SysCompany sysCompany = sysCompanyService.queryObject(id);
        return R.success().put("sysCompany", sysCompany);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys/syscompany:save")
    public R save(@RequestBody SysCompany sysCompany){
		sysCompanyService.save(sysCompany);
        return R.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys/syscompany:update")
    public R update(@RequestBody SysCompany sysCompany){
		sysCompanyService.update(sysCompany);
        return R.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys/syscompany:delete")
    public R delete(@RequestBody Long[] ids){
		sysCompanyService.deleteBatch(ids);
        return R.success();
    }

}
